﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lilium.LParse.Memoization
{
    public struct MemoizationKey : IEquatable<MemoizationKey>
    {
        public MemoizationKey(long position, Delegate parser)
        {
            Parser = parser;
            Position = position;
        }

        public override bool Equals(object obj)
        {
            if (obj is MemoizationKey)
                return Equals((MemoizationKey)obj);
            else
                return false;
        }

        public bool Equals(MemoizationKey other)
        {
            return this.Position == other.Position
                && this.Parser.Method == other.Parser.Method
                //&& проверить параметры..
                ;
        }

        public override int GetHashCode()
        {
            return Position.GetHashCode()
                ^  this.Parser.Method.GetHashCode()
                //^  получить хешь параметров
                ;
        }

        private readonly Delegate Parser;
        private readonly long Position;
    }
}